package com.chinalife.project.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolTaskExecutor() {
        return new ThreadPoolExecutor(
                16,
                200,
                60,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(512),
                runnable -> new Thread(runnable, "pool-" + runnable.hashCode()));
    }
}